package Swbclear;

import org.apache.log4j.Logger;
import Swbclear.g_tables;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import static Swbclear.g_Sqlutils.*;


public class g_tables {

    private static Logger logger = Logger.getLogger(g_tables.class);


    /**
     * 传参
     *
     * @param year
     * @param month
     * @param timeStamp
     * @param schem
     */
    public static void g_allshop(String year, String month, String timeStamp, String schem) throws SQLException {

/**
 * 考拉
 * 寺库
 * 聚美优品
 * 蜜芽
 * 贝贝
 * 顺丰优选(没有这个平台了)
 * 云集
 * 宝宝树(没有这个平台了)
 * 当当
 * 国美
 */
// "taobao|9", "tmall|10", "jd|5", "suning|3", "meituan|16", "elm|13", "dazhongdp|24"
//                        , "meituan_tg|23", "pinduoduo|20", "kaola|4", "secoo|19", "jumei|6", "miya|11", "beibei|58", "shunfeng|15", "yunji|29",
//                        "dangdang|8", "guomei|2"
//                        , "hmxs|99"
//        Connection conn = g_tables.GetConnection("dbadmin", "Goal@Data@2018");

//        "taobao|9", "tmall|10", "jd|5", "suning|3", "meituan|16", "elm|13", "dazhongdp|24"
//                , "meituan_tg|23", "pinduoduo|20", "kaola|4", "jumei|6", "miya|11", "beibei|58",  "yunji|29",
//                "guomei|2", "hmxs|99"
        Connection conn = g_tables.GetConnection("sysadmin", "Bigdata@123");

//        String[] platname_platid = {"taobao|9", "tmall|10", "jd|5", "suning|3","meituan|16",  "elm|13", "dazhongdp|24"
//                , "meituan_tg|23", "pinduoduo|20", "kaola|4", "secoo|19", "jumei|6", "miya|11", "beibei|58",  "yunji|29",
//                "dangdang|8","guomei|2", "txd|99"};//

//        String[] platname_platid = {"meituan|16", "elm|13", "suning|3", "meituan_tg|23"};
        String[] platname_platid = {"taobao|9"};

        /* 开始遍历 */
        for (String plat : platname_platid) {
            logger.info("[platformName:" + plat.split("\\|")[0] + "]");
            logger.info("[platformId:" + plat.split("\\|")[1] + "]");
            System.out.println(plat + ": =============================================");
//            g_tables.test(plat.split("\\|")[1], conn, plat.split("\\|")[0], year, month, timeStamp, schem);
            g_tables.allplat(plat.split("\\|")[1], conn, plat.split("\\|")[0], year, month, timeStamp, schem);
        }
        /**
         * 遍历插入企业个人表
         */
        for (String plat : platname_platid) {
            logger.info("[platformName:" + plat.split("\\|")[0] + "]");
            logger.info("[platformId:" + plat.split("\\|")[1] + "]");
            System.out.print(plat + ": =============================================");
            g_tables.qiyeorperson(plat.split("\\|")[1], conn, plat.split("\\|")[0], year, month, timeStamp, schem);
        }
        //更新跨境表
//        g_tables.updateoversea(conn,schem,year);
        conn.close();
    }

    public static void test(String platid, Connection conn, String platform, String year, String month, String timeStamp, String schem) {
        g_Sqlutils.o2o_bestsell_product_APP_jd_create(conn,
                "test_liu", "g_" + year + "_" + platform + "_" + month + "",
                "" + timeStamp + ""
        );

        System.out.println("11111111111111111111111111");
        g_Sqlutils.o2o_screen_ovresea_app_jd_insert(conn,
                "" + schem + "", "o2o_screen_ovresea_app_" + year + "");
    }
    /**
     * 表名 调用
     *
     * @param platid
     * @param conn
     * @param platform
     * @param year
     * @param month
     * @param timeStamp
     * @param schem
     */
    public static void allplat(String platid, Connection conn, String platform, String year, String month, String timeStamp, String schem) {


        System.out.println("===================基本店铺表=========================================================");
        logger.info("[table:o2o_allPlat_shop_BDL]");
        if (platid.equals("5") | platid.equals("10") | platid.equals("3") | platid.equals("16") | platid.equals("13")
                | platid.equals("24") | platid.equals("23")) {
            //京东，天猫，苏宁，美团，饿了么，大众点评，美团团购商铺地址规则需要镇和特别行政区
            //将北京，上海，天津，重庆错误的市信息，转换成省信息
       //test_han  start
            g_Sqlutils.o2o_allPlat_shop_BDL_tm_jd_create(conn,
                    "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_gai",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
                    "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_bu",
                    "" + timeStamp + "");

        } else if (platid.equals("9") | platid.equals("20") | platid.equals("99")) {
            //淘宝，拼多多，盒马商铺地址规则不需要镇和特别行政区
            //将北京，上海，天津，重庆错误的市信息，转换成省信息
            g_Sqlutils.o2o_allPlat_shop_BDL_taobao_pinduoduo_create(conn,
                    "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_gai",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_bu",
                    "" + timeStamp + "");
        }


        if (platid.equals("5")) {
            g_Sqlutils.o2o_allPlat_shop_BDL_tm_jd_insert(conn,
                    "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_gai",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "");
        } else if (platid.equals("10")) {

            g_Sqlutils.o2o_allPlat_shop_BDL_tm_insert(conn,
                    "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_gai",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "");
        } else if (platid.equals("9")) {

            g_Sqlutils.o2o_allPlat_shop_BDL_taobao_insert(conn,
                    "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_gai",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "");
        } else if (platid.equals("99")) {

            g_Sqlutils.o2o_allPlat_shop_BDL_hmxs_insert(conn,
                    "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_gai",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "");
        } else if (platid.equals("3") | platid.equals("16") | platid.equals("13") | platid.equals("23") | platid.equals("24") | platid.equals("20")) {

            g_Sqlutils.o2o_allPlat_shop_BDL_taobao_pinduoduo_insert(conn,
                    "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_gai",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "");
        }

        if(platid.equals("5") | platid.equals("10") | platid.equals("3") | platid.equals("16") | platid.equals("13")
                | platid.equals("24") | platid.equals("23")|platid.equals("9") | platid.equals("20") | platid.equals("99")){
        g_Sqlutils.o2o_allPlat_shop_BDL_update(conn,
                "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                "test_han", "g_" + year + "_" + platform + "_shop_" + month + "_bu",
                "" + timeStamp + "", "" + platid + "");
        }

//test_han  end




        System.out.println("===================公司信息表=========================================================");
        if (platid.equals("9") | platid.equals("10") | platid.equals("5") | platid.equals("3")) {
            //总统计淘宝，天猫，京东，苏宁公司信息
            g_Sqlutils.o2o_allPlat_shop_BDL_company_insert(conn,
                    "" + schem + "", "o2o_stand_shopCompany_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "");
//            "zf_test", "g_2020_" + platform + "_shop_04" );
        }





        System.out.println("===================畅销店铺表=========================================================");
        logger.info("[table:o2o_bestsell_shop_APP]");
        if (platid.equals("5")) {
            g_Sqlutils.o2o_bestsell_shop_APP_jd_insert(conn,
                    "" + schem + "", "o2o_bestsell_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("10")) {
            g_Sqlutils.o2o_bestsell_shop_APP_jd_tm_insert(conn,
                    "" + schem + "", "o2o_bestsell_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "activity", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("24")) {
            g_Sqlutils.o2o_bestsell_shop_APP_dazhongdp_insert(conn,
                    "" + schem + "", "o2o_bestsell_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("16") | platid.equals("13")) {
            g_Sqlutils.o2o_bestsell_shop_APP_meituan_elm_insert(conn,
                    "" + schem + "", "o2o_bestsell_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("3")) {
            g_Sqlutils.o2o_bestsell_shop_APP_suning_insert(conn,
                    "" + schem + "", "o2o_bestsell_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("20")) {
            g_Sqlutils.o2o_bestsell_shop_APP_pinduoduo_insert(conn,
                    "" + schem + "", "o2o_bestsell_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("23")) {
            g_Sqlutils.o2o_bestsell_shop_APP_meituan_tg_insert(conn,
                    "" + schem + "", "o2o_bestsell_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("9")) {
            g_Sqlutils.o2o_bestsell_shop_APP_taobao_insert(conn,
                    "" + schem + "", "o2o_bestsell_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("99")) {
            g_Sqlutils.o2o_bestsell_shop_APP_hmxs_insert(conn,
                    "" + schem + "", "o2o_bestsell_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        }



        System.out.println("===================人气店铺表=========================================================");
        logger.info("[table:o2o_sentiment_shop_APP]");
        if (platid.equals("5") | platid.equals("10")) {
            g_Sqlutils.o2o_sentiment_shop_APP_tm_jd_insert(conn,
                    "" + schem + "", "o2o_sentiment_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("16") | platid.equals("13") | platid.equals("24")) {
            g_Sqlutils.o2o_sentiment_shop_APP_meituan_elm_dazhongdp_insert(conn,
                    "" + schem + "", "o2o_sentiment_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("23")) {
            g_Sqlutils.o2o_sentiment_shop_APP_meituan_tg_insert(conn,
                    "" + schem + "", "o2o_sentiment_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        } else if (platid.equals("9")) {
            g_Sqlutils.o2o_sentiment_shop_APP_taobao_insert(conn,
                    "" + schem + "", "o2o_sentiment_shop_APP_" + year + "",
                    "" + schem + "", "o2o_allPlat_shop_BDL_" + year + "",
                    "zf_test", "g_" + year + "_" + platform + "_shop_" + month + "",
//                    "zf_test", "g_2020_" + platform + "_shop_04" ,
                    "" + platid + "", "" + timeStamp + ""
            );
        }



//test_liu start
     /*   System.out.println("===================农产品畅销单品表=========================================================");
        logger.info("[table:o2o_bestsell_product_APP]");
        if (platid.equals("9")) {
            g_Sqlutils.o2o_bestsell_product_APP_taobao_create(conn,
                    //"user_han"."g_2019_jd_07"
                    "test_liu", "g_" + year + "_" + platform + "_" + month + "",
                    "" + timeStamp + ""
            );
            //dbadmin."o2o_bestsell_product_APP_2019"
            g_Sqlutils.o2o_bestsell_product_APP_taobao_insert(conn,
                    "" + schem + "", "o2o_bestsell_product_APP_" + year + "", "" + timeStamp + ""
            );
        } else if (platid.equals("10")) {
            g_Sqlutils.o2o_bestsell_product_APP_tmall_create(conn,
                    "test_liu", "g_" + year + "_" + platform + "_" + month + "",
                    "" + timeStamp + ""
            );
            g_Sqlutils.o2o_bestsell_product_APP_tmall_insert(conn,
                    "" + schem + "", "o2o_bestsell_product_APP_" + year + ""
            );
        } else if (platid.equals("5")) {
            g_Sqlutils.o2o_bestsell_product_APP_jd_create(conn,
                    "test_liu", "g_" + year + "_" + platform + "_" + month + "",
                    "" + timeStamp + ""
            );
            g_Sqlutils.o2o_bestsell_product_APP_jd_insert(conn,
                    "" + schem + "", "o2o_bestsell_product_APP_" + year + ""
            );
        } else if (platid.equals("3")) {
            g_Sqlutils.o2o_bestsell_product_APP_suning_create(conn,
                    "test_liu", "g_" + year + "_" + platform + "_" + month + "",
                    "" + timeStamp + ""
            );
            g_Sqlutils.o2o_bestsell_product_APP_suning_insert(conn,
                    "" + schem + "", "o2o_bestsell_product_APP_" + year + ""
            );
        } else if (platid.equals("20")) {
            g_Sqlutils.o2o_bestsell_product_APP_pinduoduo_create(conn,
                    "test_liu", "g_" + year + "_" + platform + "_" + month + "",
                    "" + timeStamp + ""
            );
            g_Sqlutils.o2o_bestsell_product_APP_pinduoduo_insert(conn,
                    "" + schem + "", "o2o_bestsell_product_APP_" + year + ""
            );
        }

        System.out.println("=====================全网畅销单品表=======================================================");
        if (platid.equals("9")) {
            g_Sqlutils.bestsell_plat_taobao(conn,
                    "" + schem + "", "o2o_bestsell_APP_" + year + "",
                    "test_liu", "g_" + year + "_" + platform + "_" + month + ""
            );
        } else if (platid.equals("10") | platid.equals("5") | platid.equals("3")) {
            g_Sqlutils.bestsell_plat_tmalljdsuning(conn,
                    "" + schem + "", "o2o_bestsell_APP_" + year + "",
                    "test_liu", "g_" + year + "_" + platform + "_" + month + ""
            );
        } else if (platid.equals("16") | platid.equals("13") | platid.equals("24") | platid.equals("23")) {
            g_Sqlutils.bestsell_plat_meituan(conn,
                    "" + schem + "", "o2o_bestsell_APP_" + year + "",
                    "test_liu", "g_" + year + "_" + platform + "_" + month + ""
            );
        } else if (platid.equals("20")) {
            g_Sqlutils.bestsell_plat_pinduoduo(conn,
                    "" + schem + "", "o2o_bestsell_APP_" + year + "",
                    "test_liu", "g_" + year + "_" + platform + "_" + month + ""
            );
        }


        System.out.println("=====================农产品人气单品表=======================================================");
        logger.info("[table:o2o_sentiment_product_APP]");
        if (platid.equals("9")) {
            g_Sqlutils.o2o_sentiment_product_APP_taobao_insert(conn,
                    "" + schem + "", "o2o_sentiment_product_APP_" + year + "", timeStamp
            );
        } else if (platid.equals("10")) {
            g_Sqlutils.o2o_sentiment_product_APP_tmall_insert(conn,
                    "" + schem + "", "o2o_sentiment_product_APP_" + year + ""
            );
        }


        System.out.println("=====================价格段表=======================================================");
        logger.info("[table:o2o_products_price_APP_2019]");
        if (platid.equals("3")|platid.equals("5")|platid.equals("9")|platid.equals("10")|platid.equals("20")) {
            g_Sqlutils.o2o_products_price_APP_2019_insert(conn,
                    ""+schem+"", "o2o_products_price_APP_"+year+"",
                    "test_liu", "g_"+year+"_"+platform+"_"+month+"");
        }*/


//        System.out.println("=====================跨境大屏表=======================================================");
//        logger.info("[table:o2o_screen_ovresea_app_2019]");
//        if (platid.equals("3")) {
//            g_Sqlutils.o2o_screen_ovresea_app_suning_insert(conn,
//                    "" + schem + "", "o2o_screen_ovresea_app_" + year + "");
//        } else if (platid.equals("10")) {
//            g_Sqlutils.o2o_screen_ovresea_app_tmall_insert(conn,
//                    "" + schem + "", "o2o_screen_ovresea_app_" + year + "");
//        } else if (platid.equals("9")) {
//            g_Sqlutils.o2o_screen_ovresea_app_taobao_insert(conn,
//                    "" + schem + "", "o2o_screen_ovresea_app_" + year + "", timeStamp);
//        } else if (platid.equals("5")) {
//            g_Sqlutils.o2o_screen_ovresea_app_jd_insert(conn,
//                    "" + schem + "", "o2o_screen_ovresea_app_" + year + "");
//        } else if (platid.equals("20")) {
//            g_Sqlutils.o2o_screen_ovresea_app_pinduoduo_insert(conn,
//                    "" + schem + "", "o2o_screen_ovresea_app_" + year + "");
//        } else if (platid.equals("4") | platid.equals("19") | platid.equals("6")| platid.equals("11")| platid.equals("58") |platid.equals("15")
//                |platid.equals("29")|platid.equals("8")|platid.equals("2")) {
//            g_Sqlutils.is_oversea_plat_create(conn,
//                    "test_liu", "g_" + year + "_" + platform + "_" + month + "",
//                    timeStamp, platform);
//            g_Sqlutils.is_oversea_plat_insert(conn,
//                    "" + schem + "", "o2o_screen_ovresea_app_" + year + "", platform);
//        }
//test_liu  end
// "kaola|4","secoo|19","jumei|6","miya|11","beibei|1","shunfeng|15","yunji|29","dangdang|8","guomei|2"


    }

    /**
     * 企业或个人表
     * @param platid
     * @param conn
     * @param platform
     * @param year
     * @param month
     * @param timeStamp
     * @param schem
     */
    public static void qiyeorperson(String platid, Connection conn, String platform, String year, String month, String timeStamp, String schem){
        System.out.println("===================个人企业表=========================================================");
        if (platid.equals("9") ) {
            g_Sqlutils.o2o_allPlat_shop_BDL_companytaobao_insert(conn,
                    //user_pan."o2o_allPlat_shop_BDL_2020"
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    //dbadmin."o2o_allPlat_shop_BDL_2020"
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
                    //dbadmin."o2o_stand_shopCompany_BDL_2020"
                    ""+schem+"", "o2o_stand_shopCompany_BDL_"+year+"",
                    timeStamp);
        }else if(platid.equals("3") ){
            g_Sqlutils.o2o_allPlat_shop_BDL_companysuning_insert(conn,
                    //dbadmin."o2o_allPlat_shop_BDL_2020"
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
                    //user_pan."o2o_allPlat_shop_BDL_2020"
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
                    timeStamp);
        }else if(platid.equals("10")){
            g_Sqlutils.o2o_allPlat_shop_BDL_companytmall_insert(conn,
                    //dbadmin."o2o_allPlat_shop_BDL_2020"
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
                    //user_pan."o2o_allPlat_shop_BDL_2020"
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
                    timeStamp);
        }else if(platid.equals("16") ){
            o2o_allPlat_shop_BDL_companyqita_insert(conn,
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
                    timeStamp
            );
        }
        else if(platid.equals("13") ){
            o2o_allPlat_shop_BDL_companyqitaelm_insert(conn,
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
                    timeStamp
            );
        }
        else if(platid.equals("24") ){
            o2o_allPlat_shop_BDL_companyqitamttg_insert(conn,
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
                    timeStamp
            );
        }
        else if(platid.equals("23") ){
            o2o_allPlat_shop_BDL_companyqitadzdp_insert(conn,
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
                    timeStamp
            );
        }
        else if(platid.equals("99") ){
            o2o_allPlat_shop_BDL_companyqitahmxs_insert(conn,
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
                    timeStamp
            );
        }
        else if(platid.equals("5")){
            o2o_allPlat_shop_BDL_companyjd_insert(conn,
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
                    ""+schem+"", "o2o_stand_shopCompany_BDL_"+year+"",
                    timeStamp);
        }else if(platid.equals("20")){
            o2o_allPlat_shop_BDL_companypinduoduo_insert(conn,
                    ""+schem+"","o2o_allPlat_shop_BDL_"+year+"",
//                    "user_pan", "o2o_allPlat_shop_BDL_"+year+"",
                    "user_pan", "o2o_allPlat_shop_BDL_2020",
                    ""+schem+"", "o2o_stand_shopCompany_BDL_"+year+"",
                    timeStamp);
        }
    }


    public static void updateoversea(Connection conn,
                                     String schem, String year) {
        g_Sqlutils.is_oversea_plat_update(conn,
                "" + schem + "", "o2o_screen_ovresea_app_" + year + ""
        );
    }

    /**
     * 数据库连接
     *
     * @param username
     * @param passwd
     * @return
     */
    public static Connection GetConnection(String username, String passwd) {
        String driver = "org.postgresql.Driver";
//        String sourceURL = "jdbc:postgresql://192.168.2.148:8000/postgres";
        String sourceURL = "jdbc:postgresql://192.168.2.234:8000/postgres";
        Connection conn = null;
        try {
            //加载数据库驱动。
            Class.forName(driver).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

        try {
            //创建数据库连接。
            conn = DriverManager.getConnection(sourceURL, username, passwd);
            logger.info("Connection succeed!");
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return conn;
    }

    ;


}
